package club.wx3609.images.controller;

import club.wx3609.images.entity.Image;
import club.wx3609.images.service.ImageService;
import club.wx3609.images.service.UserService;
import com.alibaba.fastjson.JSON;
import com.wx3609_zlj.utils.CharacterProcessing.DivisionString;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
public class IndexController {

    @Resource
    private UserService userService;
    @Resource
    private ImageService imageService;

    @ResponseBody
    @PostMapping("/Request/Images/findAll")
    public String images(){
        List<Image> list=imageService.findAll();
        List<Image> lists=new ArrayList<>();
        for(Image  image:list){
            String localPath= DivisionString.spotBehind(image.getImageLocalPath(),'/');
            image.setImageLocalPath("/file/"+localPath);
            lists.add(image);
        }
        return JSON.toJSONString(lists);
    }


}
